﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //string[] s2 = File.ReadAllLines(@".//..//..//in2.txt");
            string[] s = File.ReadAllLines(@".//..//..//in.txt");
            string[] sAr = s[0].Split(' ');
            string res = "";
            int [] ar=new int [sAr.Length];
            for (int k = 0; k < sAr.Length; k++)
            {
                ar[k] = Convert.ToInt32(sAr[k]);
            }

            int m = Convert.ToInt32(s[1]);
            int n = ar.Length-m;
            int i = 0;
            int t = 0;

            while (i < n)
            {
                t = ar[ar.Length - n + i];

                for (int j = m - 1; j >= 0; j--)
                {
                    ar[j + 1 + i] = ar[j + i];
                }
                ar[i] = t;
                i++;
            }

            for (int f = 0; f<ar.Length; f++)
            {
                //sAr[f] = ar[f].ToString();
                res =res+ar[f]+" ";
            }

            File.WriteAllText(".//..//..//out.txt", res);
        }
    }
}
